export const SITE_NAME = 'VERTU AIGC'

export const presetPrompts = {
  'zh-CN': ['国足', '程序员', '独立开发者'],
  'en': ['National Team', 'Programmer', 'Independent Developer']
}

export const type = {
  'zh-CN': ['汉语新解', '玄学', '卜卦'],
  'en': ['New Chinese Interpretation', 'Metaphysics', 'Tell Fortune']
}

import bgi from './bgi.json'
import { Language } from './i18n'

// 定义模板的类型
interface TemplateData {
  title: string;
  content: string;
  image?: string;
}

export const templates: TemplateData[] = [
  // ... 你的模板数据
];

// 重命名未使用的变量
const _subtitle = '...';

// 为不同语言定义不同的SVG内容
const _href = '';

interface SvgContent {
  title: string;
  subtitle: string;
}

const getSvgContent = (lang: Language, _href: string): SvgContent => ({
  'zh-CN': {
    title: '微言威语',
    subtitle: 'Chinese Interpretation'
  },
  'en': {
    title: 'Micro Expression',
    subtitle: 'New Interpretation'
  }
}[lang])

export const presetTemplates = (base64 = '') => {
  const href = base64 || bgi.src
  
  // 定义双语模板内容
  const templateContent = {
    'zh-CN': [
      {
        prompt: '国足',
        description: '国家足球队',
        interpretation: [
          '"国足"是一个让中国人集体练习',
          '失望的社会实验，每场比赛都在',
          '考验我们的心理承受能力。'
        ]
      },
      {
        prompt: '程序员',
        description: 'Programmer',
        interpretation: [
          '现代社会的数字僧侣，',
          '用咖啡因驱动的大脑，',
          '在二进制的修道院里，',
          '编织着虚拟世界的经文。',
          '他们用键盘念咒，用代码布道，',
          '却常被世俗的bug折磨得痛不欲生。'
        ]
      },
      // ... 其他中文模板
    ],
    'en': [
      {
        prompt: 'National Team',
        description: 'Football Team',
        interpretation: [
          'A social experiment in collective',
          'disappointment, testing the psychological',
          'resilience of an entire nation.'
        ]
      },
      {
        prompt: 'Programmer',
        description: 'Code Writer',
        interpretation: [
          'Digital monks of modern society,',
          'with caffeine-driven minds,',
          'weaving virtual scriptures',
          'in binary monasteries.',
          'They chant with keyboards,',
          'preach with code,',
          'yet suffer from worldly bugs.'
        ]
      },
      // ... 其他英文模板
    ]
  }

  // 生成SVG模板函数
  const generateSvgTemplate = (content: any, lang: Language) => {
    const { title, subtitle } = getSvgContent(lang, href)
    return `<svg viewBox="0 0 400 600" xmlns="http://www.w3.org/2000/svg">
      <image href="${href}" width="100%" />
      <text x="200" y="50" font-size="32" fill="#333" text-anchor="middle">${title}</text>
      <line x1="40" y1="70" x2="360" y2="70" stroke="#333" stroke-width="1"/>
      <text x="200" y="120" font-size="28" fill="#555" text-anchor="middle">${content.prompt}</text>
      <text x="200" y="150" font-size="16" fill="#777" text-anchor="middle">${content.description}</text>
      ${content.interpretation.map((line: string, index: number) => 
        `<text x="40" y="${230 + index * 30}" font-size="20" fill="#333">${line}</text>`
      ).join('')}
    </svg>`
  }

  // 返回所有语言的模板
  return ['zh-CN', 'en'].map(lang => 
    templateContent[lang as Language].map(content => ({
      prompt: content.prompt,
      svg: generateSvgTemplate(content, lang as Language)
    }))
  ).flat()
}
